Fix new-thread draft reuse for worktree defaults#2003
Conversation
- Prefer worktree mode when the server default is worktree - Avoid reusing promoting drafts as the source for new threads - Preserve existing worktree drafts instead of deleting them
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Small bug fix adding guard conditions to prevent incorrect draft thread reuse when worktree defaults are set or when drafts are being promoted. Production changes are minimal (~12 lines) with defensive null/state checks, accompanied by comprehensive test coverage (~114 lines). Low-risk, well-scoped fix. You can customize Macroscope's approvability policy. Learn more. |
Summary
worktree.Testing
bun fmtbun lintbun typecheckbun run testNote
Medium Risk
Touches new-thread draft creation/reuse logic and draft-store cleanup rules, which can impact routing and draft persistence across projects. Changes are localized and covered by new unit and browser-level tests, reducing regression risk.
Overview
New-thread draft reuse is tightened for worktree defaults and promotion in-flight. When the project default env mode is
worktree, sidebar seed context now forcesenvMode: "worktree"instead of inheriting an active thread’s branch/worktree path, ensuring the next thread starts as a fresh worktree draft.Draft reuse/cleanup is also guarded so promoting draft threads aren’t reused or deleted mid-promotion (
useHandleNewThreadcheckspromotedTo == null;composerDraftStorewon’t evict a prior draft if it’s promoting). Adds regression coverage inChatView.browser.tsxandSidebar.logic.test.ts.Reviewed by Cursor Bugbot for commit 33d6b03. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix new-thread draft reuse when the default environment mode is worktree
useHandleNewThread.ts, draft reuse is now skipped when the active draft has already been promoted (promotedTo != null).composerDraftStore.ts, deletion of a previous logical-project draft is skipped when that draft is in a promoting state.Sidebar.logic.ts,resolveSidebarNewThreadSeedContextreturns{ envMode: 'worktree' }immediately whendefaultEnvModeis'worktree', ignoring any active thread context.Macroscope summarized 33d6b03.